/**
 * Created by Handsome.Ho on 2015/10/13.
 */
angular.module('cloud.services', []).provider('cloud', function () {
  this.cloudUrl = null;
  var that = this;
  this.$get = function ($http) {
    return {
      validate: function (username, password, success, fail) {
        var url = that.cloudUrl + '/accounts/' + username + '/' + password;
        $http({
          method: 'GET',
          url: url
        }).success(function (data) {
          if (data.bsuccess && success) {
            success(data.data);
          } else {
            fail(data.data);
          }
        }).error(function (data) {
          fail(data);
        });
      }
    };
  }
});
